package rightsmanagement;

public class PairUserNameAndPW {
	private String userName;
	private String userPassword;

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getUserPassword() {
		return userPassword;
	}

	public void setUserPassword(String userPassword) {
		this.userPassword = userPassword;
	}

	public PairUserNameAndPW(String uName, String uPW) {
		userName = uName;
		userPassword = uPW;
	}

	public boolean equals(Object o) {
		if (o == null) {
			return false;
		}
		if (!(o instanceof PairUserNameAndPW)) {
			return false;
		}
		PairUserNameAndPW converted = (PairUserNameAndPW) o;
		if (!this.getUserName().equals(converted.getUserName())) {
			return false;
		}
		if (!this.getUserPassword().equals(converted.getUserPassword())) {
			return false;
		}
		return true;
	}

	public int hashCode() {
		char[] name = this.getUserName().toCharArray();
		char[] pw = this.getUserPassword().toCharArray();
		int count = 0;
		int sum = 0;
		boolean cutter = false;
		boolean anothercutter = false;
		while (cutter == false && anothercutter == false) {
			if (count < name.length) {
				sum += new Integer(name[count]);
			} else
				cutter = true;
			if (count < pw.length) {
				sum += new Integer(pw[count]);
			} else
				anothercutter = true;
			count++;
		}
		return sum;
	}
}
